package com.xymtop.api.utils;

/**
 * @ClassName : JsonResoult
 * @Description : 规范返回的数据
 * @Author : 肖叶茂
 * @Date: 2022/12/1  10:50
 */
public class JsonResoult<E> {
    //响应状态码 200-成功 4000-用户名重复 5000-数据库或服务器异常
    private int status;
    //响应信息
    private String message;
    //响应数据
    private E data;

    /**
    *@Description:输入状态返回
    *@Parameter:[status]
    *@Return:
    *@Author:肖叶茂
    *@Date:2022/12/1
    **/
    public JsonResoult(int status) {
        this.status = status;
    }

    /**
    *@Description:可定义返回值和数据
    *@Parameter:[status, data]
    *@Return:
    *@Author:肖叶茂
    *@Date:2022/12/1
    **/
    public JsonResoult(int status, E data) {
        this.status = status;
        this.data = data;
    }

    public JsonResoult(int status, String message, E data) {
        this.status = status;
        this.message = message;
        this.data = data;
    }

    /**
    *@Description:msg消息为报错信息
    *@Parameter:[e]
    *@Return:
    *@Author:肖叶茂
    *@Date:2022/12/1
    **/
    public JsonResoult(Throwable e ) {
        this.message = e.getMessage();
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public E getData() {
        return data;
    }

    public void setData(E data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "JsonResoult{" +
                "status=" + status +
                ", message='" + message + '\'' +
                ", data=" + data +
                '}';
    }
}
